<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>面向对象的继承</title>
	</head>
	<body>
		<script>
			function Foo(){//父类
				this.name = "hello";
			}
			Foo.prototype.showName(){
				console.log(this.name);
			};
			function Bar(){//子类
				Foo.call(this);
				this.age = 20;
			}
			exent(Bar,Foo);
			Bar.prototype.showAge(){
				console.log(this.age);
			}
			function exent(subs,sups){//拷贝继承
				for(var attr in subs.prototype){
					subs.prototype[attr] = sups.prototype[attr];
				}
			}
			/* function exent(subs,sups){//类式继承
				var F = function(){};
				F.prototype = sups.prototype;
				subs.prototype = new F();
				subs.prototype.constructor = subs;
			} */
			var obj1 = new Foo();
			var obj2 = new Bar();
			console.log(obj1);
			console.log(obj2);
			
		</script>
	</body>
</html>
